<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.beaut.project.util.FlowUtility" %>
<%@ include file="/public/header.jsp"%>
<html>
	<head>
		<title>关闭的项目</title>
	</head>
	<script type="text/javascript">
		$(function(){
			$("#searchValue").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch();
		       	} 
		   	}); 
			$("#dept_id").combotree({
				url:'<%=contextPath %>/springMVC/group/listDepartment',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch();
				}
			});
			jQuery("#searchValue2").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch2();
		       	} 
		   	}); 
			jQuery('#admin_id').combogrid({
				title:'立项人选择',
				mode:"remote",
				loadMsg:'正在加载数据，请稍后......',
				panelWidth:550,
				panelHeight:400,
				url:"<%=contextPath%>/springMVC/group/listPageUser",
				idField:"id",
				textField:"truename",
				rownumbers:true,
				fitColumns:true,
				columns: [[
					{field:'id',hidden:true},
					{field:'deptId',hidden:true},
					{field:'truename',title:'姓名',width:100},
					{field:'deptName',title:'所属部门',width:100},
					{field:'privName',title:'角色',width:100}
				]],
				toolbar:"#tba",
				pageSize:10,
				pageList:[10,50,100],  
				pagination:true,
				onChange:function(){
					doSearch();
				}
			});
			jQuery("#p_dept_id").combotree({
				url:'<%=contextPath %>/springMVC/group/listDepartment',
				method:'POST',
				animate:true,
				lines:true,
				onChange:function(){
					doSearch2();
				}
			});
			$("#table").datagrid({
				title:"关闭的项目",
				iconCls:'icon-edit',
				loadMsg:'正在加载数据，请稍后......',
				url:'<%=contextPath %>/springMVC/xm/listPageXMBase?xm_progress_status=8',
				rownumbers:true,
				fitColumns:true,
				nowrap:false,
				idField:'id',
				frozenColumns:[[
				    {title:'主键',field:'id',hidden:true},
				]],
				columns:[[
					{title:'立项人',field:'admin_name',width:100,align:'center'},
					{title:'所属部门',field:'admin_dept',width:100,align:'center'},
					{title:'项目编号',field:'xm_code',width:100,align:'center'},
					{title:'项目名称',field:'xm_name',width:200,align:'center'},
					{title:'客户',field:'customer',width:120,align:'center'},
					{title:'是否发起无合同申请',field:'contract_type',hidden:true},
					{title:'开工时间',field:'start_time',width:100,align:'center'},
					{title:'完工时间',field:'end_time',width:100,align:'center'},
					{title:'绑定工单数量',field:'xm_gds_num',width:100,align:'center'}
				]],
				view: detailview,
				detailFormatter:function(index,row){
					return '<div style="padding:2px"><table class="ddv"></table></div>';
				},
				onExpandRow: function(index,row){
					var xm_id = row.id;
					var xm_flow_status = row.xm_flow_status;
					var ddv = $(this).datagrid('getRowDetail',index).find('table.ddv');
					var url="";
					if(xm_flow_status == 0){
						url = "<%=contextPath%>/springMVC/gd/listPageTmpGd?xm_id="+xm_id;
					}else{
						url="<%=contextPath%>/springMVC/gd/listGd?xm_id="+xm_id;
					}
					 ddv.datagrid({
						title:'工单明细',
						url:url,
						loadMsg:'正在加载数据，请稍后......',
						fitColumns:true,
						rownumbers:true,
						columns:[[
							{title:'工单id',field:'id',hidden:true},
							{title:'工单内容id',field:'gd_content_id',hidden:true},
							{title:'工单状态',field:'gd_status',hidden:true},
							{title:'工单进度',field:'gd_status_desc',width:50,align:'center'},
							{title:'工单编号',field:'gd_code',width:100,align:'center'},
							{title:'工单名称',field:'gd_name',width:200,align:'center'},
							{title:'开工日期',field:'gd_start',width:150,align:'center'},
							{title:'完工日期',field:'gd_actual_end',width:150,align:'center'},
							{title:'操作',field:'edit',width:80,align:'center',formatter:function(value,rowData,rowIndex){
								return "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='查看详情' onclick=\"javascript:showGD('"+rowData.id+"','"+rowData.gd_content_id+"');\"/>";
							}}
						]],
						pageSize:10,
						pageList : [10,50,100],  
						pagination:true,
					 	onResize:function(){
					        $('#table').datagrid('fixDetailRowHeight',index);
					    },
					 	onLoadSuccess:function(){
					       setTimeout(function(){
					         $('#table').datagrid('fixDetailRowHeight',index);
					       },0);
					   }
					 });
					 $('#table').datagrid('fixDetailRowHeight',index);
				},
				toolbar:"#tb",
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						$.messager.alert('提示',rtJson.rtMsrg);
					}
				}
			});
		});
		function showGD(gd_id,gd_content_id){
			openDialogResize('<%=contextPath%>/springViews/gd/showGd.jsp?gd_id='+gd_id+'&gd_content_id='+gd_content_id,1000, 800);
		}
		function  viewData(id,xm_flow_status){
			openDialogResize("<%=contextPath %>/springViews/xm/addOrEditXm.jsp?xm_id="+id+"&callback=rtCallBack&isShow=1&xm_flow_status="+xm_flow_status,1000, 800);
	
		}
		function rtCallBack(){
			$('#table').datagrid('reload');
		}
		function doSearch() {
			var searchValue = $('#searchValue').val();
			var dept_id = $("#dept_id").combotree('getValue');
			var admin_id = jQuery("#admin_id").combotree('getValue');
			$('#table').datagrid('load', {
				searchValue : searchValue,
				dept_id : dept_id,
				admin_id:admin_id
			});
		}
	
		function doSearch2() {
			var dept_id = jQuery('#p_dept_id').combotree('getValue');
			var searchValue = jQuery('#searchValue2').val();
			jQuery('#admin_id').combogrid("grid").datagrid('load', {
				searchValue : searchValue,
				dept_id:dept_id
			});
		}

	</script>
	<body style="height: 97%">
	<div id="table" data-options="fit:true"></div>
	<div id="tb" style="padding:3px;height:auto">
		<div align="right">
			立项人：<input type="text" id="admin_id" name="admin_id"   style="width:100px"> &nbsp;&nbsp;
			所属部门：<input  id="dept_id" name="dept_id" class="easyui-combotree">&nbsp;&nbsp; 
			项目编号/名称：<input id="searchValue" name="searchValue" style="width:150px" title="项目编号/名称" placeholder="项目编号/名称 "  />&nbsp;&nbsp; 
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
		</div>
	</div>
	<div id="tba" style="padding:3px;height:auto">
			<div align="right">
			             所属部门：<input  id="p_dept_id" name="p_dept_id"  style="width:150px"  class="easyui-combotree">
				查询条件：<input id="searchValue2" name="searchValue2" style="width:150px" title="用户名称或者用户真实姓名"/>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch2();"></a>
			</div>
		</div>
	
</body>
</html>